<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8" />
	<title>千郡医疗-添加银行卡</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta name="format-detection" content="telephone=no" />
	<link rel="stylesheet" th:href="@{/weixin/css/style.css}" />
	<link rel="stylesheet" th:href="@{/weixin/css/weui.min.css}" />
	<script th:src="@{/weixin/js/adaptive.js}"></script>
	<script th:src="@{/weixin/js/fastclick.min.js}"></script>
	<script th:src="@{/weixin/js/zepto.min.js}"></script>
	<script type="text/javascript" th:src="@{/weixin/js/weui.min.js}"></script>
	<style type="text/css">
	 body{font-size: initial !important;}
	</style>
</head>
<body>
	<section class="agentPage">
		<p class="top">请输入要绑定的银行卡</p>
		<form id="form">
		<input type="hidden" name="customerId" th:value="${customerId}" />
		<ul>
			<li>
				<p>持卡人</p>
				<p><input type="text" name="customerName" id="customerName" class="txt" placeholder="请输入持卡人姓名" /></p>
			</li>
			<li>
				<p>卡号</p>
				<p><input type="text" name="bankCardNum"  id="bankCardNum" class="txt" placeholder="请输入银行卡卡号" /></p>
			</li>
		</ul>
		</form>
		<p class="btm">
			<a href="javascript:" id="submit" class="comBtn">添加银行卡</a>
		</p>
	</section>
	<script type="text/javascript">
	$(function(){
		$("#submit").click(function() {
			if (!validate())
				return;

			var l = weui.loading("正在提交")
			$.ajax({
				cache : true,
				type : "POST",
				url : "/qianjun/weixin/bank/add",
				data : $('#form').serialize(),
				error : function(request) {
					l.hide();
					weui.alert("添加失败");
				},
				success : function(data) {
					l.hide();
					if(!data.success){
						weui.alert(data.msg);
						return;
					} 
					location.href = "/qianjun/weixin/bank";
				}
			});
		})
	})
	
	function validate() {
		if($("#customerName").val() == ''){
			weui.alert("持卡人姓名不能为空");
			return false;
		}

		if(!(/^\d{6,}$/.test($("#bankCardNum").val()))){ 
	        weui.alert("请输入正确的卡号");  
	        return false; 
	    } 		

		return true;
	}
	
	</script>
</body>
</html>